import logging
import os

import allure


from utils.ocr_utils import get_res_sn_captcha

@allure.step("1.解析请求数据")
def analyse_case(case):
    method = case["method"]
    #从环境遍历中获取
    url = os.environ["URL"] + case["path"]
    headers = eval(case["headers"]) if isinstance(case["headers"], str) else None
    params = eval(case["params"]) if isinstance(case["params"], str) else None
    data = eval(case["data"]) if isinstance(case["data"], str) else None
    json = eval(case["json"]) if isinstance(case["json"], str) else None
    files = eval(case["files"]) if isinstance(case["files"], str) else None
    request_data = {
        "method": method,
        "url": url,
        "headers": headers,
        "params": params,
        "data": data,
        "json": json,
        "files": files
    }
    logging.info(f"1.请求解析数据{request_data}")
    allure.attach(f"1.请求解析数据{request_data}",name = "解析数据结果")
    return request_data